package com.mlink.ai.chat.firebase

import com.adsdk.android.ads.OxAdSdkManager
import com.mlink.ai.chat.assistant.robot.R
import com.icekrvams.air.firebase.RemoteConfigHelper
import com.mlink.ai.chat.AiChatApplication

class ChatRemoteConfig {

    companion object {
        private const val CACHE_EXPIRATION: Long = 3600
    }

    init {
        RemoteConfigHelper.setDefaultsAsync(R.xml.firebase_remote_config_defaults)
    }

    fun getBoolean(key: String) = RemoteConfigHelper
        .getBoolean(key)

    fun getString(key: String) = RemoteConfigHelper
        .getString(key)

    fun getDouble(key: String) = RemoteConfigHelper
        .getDouble(key)

    fun getLong(key: String) = RemoteConfigHelper
        .getLong(key)

    fun fetchConfig() {
        RemoteConfigHelper.get().fetch(CACHE_EXPIRATION)
            .addOnCompleteListener { task ->
                if (task.isSuccessful) {
                    OxAdSdkManager.getInstance().switchMediationPlatformByRemoteConfig(
                        AiChatApplication.app
                    ) {

                    }
                }
            }
    }
}
